<?php
session_start();
if(isset($_SESSION['username'])){ 
	$user = $_SESSION['username'];
	$userid = $_GET['userid'];
	$menu_name = $_GET['menu_name'];
	
	mysql_connect("localhost","yinch838","yinch838-09")	or die(`Could not connect: ` . mysql_error());
	@mysql_select_db("yinch838") or die(mysql_error());

	
	$query="SELECT menuid
		FROM menu
		WHERE userid='$userid'
		AND name='$menu_name'";			
	$result = mysql_query($query) or die(mysql_error());
	$menuid = mysql_fetch_object($result)->menuid;
	
	$query="DELETE FROM product WHERE menuid = '$menuid'";
	$result = mysql_query($query) or die(mysql_error());
	
	$query="DELETE FROM menu WHERE name = '$menu_name' AND userid = '$userid'";
	$result = mysql_query($query) or die(mysql_error());
	
	header("Location: ../php/restaurant.php");
}

else{
	header("Location: ../xml/login.xml");
}
?>